package treqs;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class myConnection {

	Connection connection;
	Statement statement;

	public myConnection()
	{
		connection=null;
		statement=null;
	}

	public myConnection(String driverClass,String connectionURL,String user,String password)
	{
		try
		{
			Class.forName(driverClass).newInstance();
			connection=DriverManager.getConnection(connectionURL,user,password);
			statement=connection.createStatement();
		}

		catch (InstantiationException e)
		{
			e.printStackTrace();
		}

		catch (SQLException e)
		{
			e.printStackTrace();
		}

		catch (IllegalAccessException e)
		{
			e.printStackTrace();
		}

		catch (ClassNotFoundException e)
		{
			e.printStackTrace();
		}
	}

	public void setStatement(Statement statement)
	{
		this.statement = statement;
	}

	public Statement getStatement()
	{
		return statement;
	}

	public String getUserList(String user)
	{

		try
		{
			ResultSet result=statement.executeQuery("Select * from requirements;");

			while(result.next())
			{
				return result.getString(3);
			}
		}

		catch (SQLException e)
		{
			e.printStackTrace();

		}

		return new String("ola error");

	}
	
	public String getIt(int entry)
	{
return getUserList("1");
		
	}
}

